<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>商家管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="../plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/toastr/toastr.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/js/toastr/toastr.css">

</head>

<body class="hold-transition skin-red sidebar-mini">
<!-- .box-body -->
<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">商家管理</h3>
    </div>

    <div class="box-body">

        <!-- 数据表格 -->
        <div class="table-box">

            <!--工具栏-->

            <div class="box-tools pull-right">
                <div class="has-feedback">
                    公司名称：<input type="text" id="name" name="name">
                    店铺名称： <input type="text" id="nickName" name="nickName">
                    状态：
                    <input type="radio" name="status" checked="checked" value=""/>全部
                    <input type="radio" name="status" value="0"/>待审核
                    <input type="radio" name="status" value="1"/>已审核
                    <input type="radio" name="status" value="2"/>审核未通过
                    <input type="radio" name="status" value="3"/>关闭
                    <button class="btn btn-default" onclick="show()">查询</button>
                </div>
            </div>
            <!--工具栏/-->

            <!--数据列表-->
            <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                <thead>
                <tr>
                    <th class="" style="padding-right:0px">
                        <input id="selall" type="checkbox" class="icheckbox_square-blue">
                    </th>
                    <th class="sorting_asc">商家ID</th>
                    <th class="sorting">公司名称</th>
                    <th class="sorting">店铺名称</th>
                    <th class="sorting">联系人姓名</th>
                    <th class="sorting">公司电话</th>
                    <th class="sorting">状态</th>
                    <th class="text-center">操作</th>
                </tr>
                </thead>
                <script>
                    $(function () {
                        show();
                    })

                    function show() {
                        $.ajax({
                            url: "/seller/getSeller",
                            data: {
                                name: $("#name").val(),
                                nickName: $("#nickName").val(),
                                status: $("[name=status]:checked").val(),
                                pageNum: $("#pageNumber").val(),
                                pageSize: $("#pageSize").val()
                            },
                            type: "get", //请求方式 get post 默认get
                            dataType: "json", //返回值类型 html json text xml
                            async: true,//true代表异步请求 false代表同步请求
                            success: function (result) {//成功回调函数
                                var page = result.data.rows;
                                var div = "";
                                for (var i = 0; i < page.length; i++) {
                                    div += '<tr>';
                                    div += '<td><input type="checkbox" name="check" value="' + page[i].sellerId + '"></td>';
                                    div += '<td>' + page[i].sellerId + '</td>';
                                    div += '<td>' + page[i].name + '</td>';
                                    div += '<td>' + page[i].nickName + '</td>';
                                    div += '<td>' + page[i].linkmanName + '</td>';
                                    div += '<td>' + page[i].mobile + '</td>';
                                    div += "<td>"
                                    if (page[i].status ==2){
                                        div += " 审核通过 ";
                                    }else if (page[i].status == 0){
                                        div += "审核未通过";
                                    }else if (page[i].status == 1) {
                                        div += "待审核审核";
                                    }
                                    div += "</td>";
                                    div += '<td className=\"text-center\">';
                                    div += '<button type="button" onclick="toUpdate(\''+ page[i].sellerId +'\')" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#sellerModal" >详情</button>';
                                    div += "</td>";
                                    div += "</tr>";

                                }
                                $("#seller").html(div);
                                install_page(result.data)
                            },
                            error: function (i) {//发生错误回调函数
                                alert("异常错误")
                            }

                        })
                    }
                </script>

                <tbody id="seller">

                </tbody>
                <div th:insert="/common/page.html"></div>
            </table>
            <!--数据列表/-->


        </div>
        <!-- 数据表格 /-->


    </div>
    <!-- /.box-body -->
</div>


<!-- 商家详情 -->
<div class="modal fade" id="sellerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel">商家详情</h3>
            </div>
            <div class="modal-body">

                <ul class="nav nav-tabs">
                    <li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
                    <li><a href="#linkman" data-toggle="tab">联系人</a></li>
                    <li><a href="#certificate" data-toggle="tab">证件</a></li>
                    <li><a href="#ceo" data-toggle="tab">法定代表人</a></li>
                    <li><a href="#bank" data-toggle="tab">开户行</a></li>
                </ul>
                <script>
                    function toUpdate(sellerId) {
                        $.ajax({
                            url: "/seller/toUpdate/" + sellerId,
                            type: "get", //请求方式 get post 默认get
                            dataType: "json", //返回值类型 html json text xml
                            async: true,//true代表异步请求 false代表同步请求
                            success: function (result) {//成功回调函数
                                var page = result.data;
                                $("#statusIdaa").val(page.sellerId);
                                $("#pass").html(page.status);
                                $("#name1").html(page.name);
                                $("#mobile").html(page.mobile);
                                $("#telephone").html(page.telephone);
                                $("#address_detail").html(page.addressDetail);
                                $("#linkman_name").html(page.linkmanName);
                                $("#linkman_qq").html(page.linkmanQq);
                                $("#linkman_mobile").html(page.linkmanMobile);
                                $("#linkman_email").html(page.linkmanEmail);
                                $("#license_number").html(page.licenseNumber);
                                $("#tax_number").html(page.taxNumber);
                                $("#org_number").html(page.orgNumber);
                                $("#bank_user").html(page.bankUser);
                            },
                            error: function (i) {//发生错误回调函数
                                alert("异常错误")
                            }

                        })
                    }
                </script>
                <!-- 选项卡开始 -->
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <br>
                        <table class="table table-bordered table-striped" width="800px">
                            <tr>
                                <td>公司名称</td>
                                <td id="name1"></td>
                            </tr>
                            <tr>
                                <td>公司手机</td>
                                <td id="mobile"></td>
                            </tr>
                            <tr>
                                <td >公司电话</td>
                                <td id="telephone"></td>
                            </tr>
                            <tr>
                                <td>公司详细地址</td>
                                <td id="address_detail"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="tab-pane fade" id="linkman">
                        <br>
                        <table class="table table-bordered table-striped">
                            <tr>
                                <td>联系人姓名</td>
                                <td id="linkman_name"></td>
                            </tr>
                            <tr>
                                <td>联系人QQ</td>
                                <td id="linkman_qq"></td>
                            </tr>
                            <tr>
                                <td>联系人手机</td>
                                <td id="linkman_mobile"></td>
                            </tr>
                            <tr>
                                <td>联系人E-Mail</td>
                                <td id="linkman_email"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="tab-pane fade" id="certificate">
                        <br>
                        <table class="table table-bordered table-striped">
                            <tr>
                                <td>营业执照号</td>
                                <td id="license_number"></td>
                            </tr>
                            <tr>
                                <td>税务登记证号</td>
                                <td id="tax_number"></td>
                            </tr>
                            <tr>
                                <td>组织机构代码证号</td>
                                <td id="org_number"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="tab-pane fade" id="ceo">
                        <br>
                        <table class="table table-bordered table-striped">
                            <tr>
                                <td>法定代表人</td>
                                <td id="legal_person"></td>
                            </tr>
                            <tr>
                                <td>法定代表人身份证号</td>
                                <td id="legal_person_card_id"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="tab-pane fade" id="bank">
                        <br>
                        <table class="table table-bordered table-striped">
                            <tr>
                                <td>开户行名称</td>
                                <td id="bank_user"></td>
                            </tr>
                            <tr>
                                <td>开户行支行</td>
                                <td>海淀支行</td>
                            </tr>
                            <tr>
                                <td>银行账号</td>
                                <td>999000111222</td>
                            </tr>
                            <input type="text" id ="statusIdaa">
                        </table>
                    </div>
                </div>
                <!-- 选项卡结束 -->
                <script>
                    function pass() {
                        $.ajax({
                            url: "/seller/pass",
                            data:{sellerId:$("#statusIdaa").val()},
                            type: "get", //请求方式 get post 默认get
                            dataType: "json", //返回值类型 html json text xml
                            async: false,//true代表异步请求 false代表同步请求
                            success: function (result) {//成功回调函数
                                if (result.code == 10000){
                                    toastr.success("审核通过");
                                    setTimeout("refresh()", 1000);//3秒后执行refresh()
                                }else {
                                    toastr.error("已审核通过哦");
                                    setTimeout("refresh()", 1000);//3秒后执行refresh()
                                }
                            },
                            error: function (i) {//发生错误回调函数
                                alert("异常错误")
                            }
                        })
                    }
                    function noPass() {
                        $.ajax({
                            url: "/seller/noPass",
                            data:{sellerId:$("#statusIdaa").val()},
                            type: "get", //请求方式 get post 默认get
                            dataType: "json", //返回值类型 html json text xml
                            async: false,//true代表异步请求 false代表同步请求
                            success: function (result) {//成功回调函数
                                if (result.code == 10000){
                                    toastr.success("审核通过");
                                    setTimeout("refresh()", 1000);//3秒后执行refresh()
                                }else {
                                    toastr.error("已审核通过哦");
                                    setTimeout("refresh()", 1000);//3秒后执行refresh()
                                }
                            },
                            error: function (i) {//发生错误回调函数
                                alert("异常错误")
                            }
                        })
                    }
                    //刷新函数
                    function refresh() {
                        window.location.reload();
                    }
                </script>


            </div>
            <div class="modal-footer">
                <button class="btn btn-success" data-dismiss="modal" aria-hidden="true"  onclick="pass()">审核通过</button>
                <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true"  onclick="noPass()">审核未通过</button>
                <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">关闭商家</button>
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
            </div>
        </div>
    </div>
</div>


</body>

</html>